package ar.com.ctrln.persistence.model.liquidacion;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.apache.commons.lang.builder.HashCodeBuilder;

@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Componente {

	public static final String unidad_porcentaje = "%";
	public static final String unidad_peso = "$";

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	@Column(name = "id_componente")
	private long id;

	@Column
	private String nombre;

	@Column
	private Date fecha;

	@Column
	private Double importe;

	@Column
	private double total;

	@Column
	private String observacion;

	@Column
	private String simbolo;

	@ManyToOne
	@JoinColumn(name = "id_detalle")
	private DetalleLiquidacion detalle;

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getNombre() {
		return nombre;
	}

	public void setNombre(String nombre) {
		this.nombre = nombre;
	}

	public Date getFecha() {
		return fecha;
	}

	public void setFecha(Date fecha) {
		this.fecha = fecha;
	}

	public Double getImporte() {
		return importe;
	}

	public void setImporte(Double importe) {
		this.importe = importe;
	}

	public double getTotal() {
		return total;
	}

	public void setTotal(double total) {
		this.total = total;
	}

	public String getObservacion() {
		return observacion;
	}

	public void setObservacion(String observacion) {
		this.observacion = observacion;
	}

	public DetalleLiquidacion getDetalle() {
		return detalle;
	}

	public void setDetalle(DetalleLiquidacion detalle) {
		this.detalle = detalle;
	}

	public String getSimbolo() {
		return simbolo;
	}

	public void setSimbolo(String simbolo) {
		this.simbolo = simbolo;
	}

	public abstract String getValorImporte();

	@Override
	public boolean equals(Object obj) {

		return (obj instanceof Componente && getId() == ((Componente) obj)
				.getId());
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder(17, 37).append(getFecha())
				.append(getNombre()).toHashCode();
	}


}
